package com.spn.blog.api.controller.system;

import com.spn.blog.common.vo.Result;
import com.spn.blog.common.vo.params.LoginParam;
import com.spn.blog.service.login.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "系统模块")
@RestController
@RequestMapping("api/register")
public class RegisterController {

    @DubboReference(check = false)
    private LoginService loginService;



    @ApiOperation(value = "用户注册")
    @PostMapping
    public Result register(@RequestBody LoginParam loginParam){
        //sso 单点登录，后期如果把登录注册功能 提出去（单独的服务，可以独立提供），
        //TODO： bug（用户注册之后，没有进行ip地址记录）
        System.out.println("注册controller");
        return loginService.register(loginParam);
    }

    @ApiOperation(value = "邮箱验证码发送")
    @PostMapping("sendEmail")
    public Result sendVCode(@ApiParam("邮箱") @RequestBody Map<String,String> map){
        String email = map.get("email");
        return loginService.sendVCode(email);
    }
}
